/**
 * @author Lei
 * @create 2022-05-22 18:00
 */
public class ControllerCreate extends Controller {
    public ControllerCreate(Library m) {
        super(m);
    }

    public String create(String name, String number, int type) {
        try {
            int nextInt = Integer.parseInt(number);
            IUser user = null;
            if (type == 0) {
                user = new Lender(name, nextInt);
            } else {
                user = new Borrower(name, nextInt);
            }
            m.addUser(user);
            return "";
        } catch (NumberFormatException | NotALenderException e) {
            return e.getMessage();
        }

    }
}
